
public class RPNCalculator {

	private CalculatorStack stack = new CalculatorStack();
	private MathOperatorFactory factory;

	public RPNCalculator(MathOperatorFactory factory) {
		this.factory = factory;
	}

	public double getAccumulator() {
		 return stack.peek();
	}

	public void setAccumulator(double value) {
		stack.poke(value);
	}

	public void enter() {
		stack.push( getAccumulator() );
	}
	
	public void drop() {
		stack.pop();
	}

	public void execute(String operator) {
		factory.getMathOperatorFor(operator).execute(stack);
	}
}
